package 数据结构.排序编程作业;

import java.util.Scanner;

/**
 * @author IT_Jay
 * @date 2021/12/8 3:33 PM
 */
public class T3 {
    public static Boolean isFirst =true;
    public static int temp_index = 1;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int length = scanner.nextInt();
        int arr[] = new int[length];
        for (int i = 0; i < length; i++) {
            arr[i] = scanner.nextInt();
        }
        quick_sort(arr,0,length-1);
        System.out.print(temp_index+" ");
        for (int item:arr) System.out.print(item+" ");
    }

    public static void quick_sort(int a[], int l, int r){
        if (l<r){
            int temp_left,temp_right,x;
            temp_left = l;
            temp_right = r;
            x= a[temp_left];
            while (temp_left<temp_right){
                while (temp_left<temp_right && a[temp_right]>x) temp_right--;
                if (temp_left<temp_right) a[temp_left++]=a[temp_right];
                while (temp_left<temp_right && a[temp_left]<x) temp_left++;
                if (temp_left<temp_right) a[temp_right--] = a[temp_left];
            }
            a[temp_left]=x;
            if(isFirst){
                temp_index= temp_left+1;
                isFirst=false;
            }
            quick_sort(a,l,temp_left-1);
            quick_sort(a,temp_left+1,r);
        }
    }
}
